package com.spar.openprojects.shared;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.google.gwt.user.client.rpc.IsSerializable;

public class Order implements IsSerializable {
	private Integer id;
	private Integer projectId;
	
	private Boolean everyYear;
	private OrderItem offer = new OrderItem();
	private OrderItem order = new OrderItem();
	
	private List<OrderItem> bills = new ArrayList<OrderItem>();
	
	private BusinessPartner businessPartner = new BusinessPartner();
	
	private Date updated = new Date();
	private Date created = new Date();
	
	private Member updateMember = new Member();
	private Member createMember = new Member();
	
	
	
	
	public Boolean getEveryYear() {
		return everyYear;
	}
	public void setEveryYear(Boolean everyYear) {
		this.everyYear = everyYear;
	}
	public OrderItem getOffer() {
		return offer;
	}
	public void setOffer(OrderItem offer) {
		this.offer = offer;
	}
	public OrderItem getOrder() {
		return order;
	}
	public void setOrder(OrderItem order) {
		this.order = order;
	}
	public List<OrderItem> getBills() {
		return bills;
	}
	public void setBills(List<OrderItem> bills) {
		this.bills = bills;
	}

	
	

	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getProjectId() {
		return projectId;
	}
	public void setProjectId(Integer projectId) {
		this.projectId = projectId;
	}	
	public BusinessPartner getBusinessPartner() {
		return businessPartner;
	}
	public void setBusinessPartner(BusinessPartner businessPartner) {
		this.businessPartner = businessPartner;
	}
	public Date getUpdated() {
		return updated;
	}
	public void setUpdated(Date updated) {
		this.updated = updated;
	}
	public Date getCreated() {
		return created;
	}
	public void setCreated(Date created) {
		this.created = created;
	}
	
	public Member getUpdateMember() {
		return updateMember;
	}
	public void setUpdateMember(Member updateMember) {
		this.updateMember = updateMember;
	}
	public Member getCreateMember() {
		return createMember;
	}
	public void setCreateMember(Member createMember) {
		this.createMember = createMember;
	}
	
	
	public Double getBillAmount() {
		Double amount = 0D;
		for (OrderItem bill : bills) {
			if (bill.getAmount() != null)
				amount += bill.getAmount();
		}
		return amount;
	}
	public void persist() {
		
	}

}
